package com.javaee.web.servlet;
import java.io.IOException;
import java.util.List;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.javaee.ejb.entity.Activity;
import com.javaee.ejb.entity.Project;
import com.javaee.ejb.session.remote.ActivityManagerRemote;
import com.javaee.ejb.session.remote.ProjectManagerRemote;
import com.javaee.web.HttpServletBase;
import com.javaee.web.SiteParameters;

/**
 * Servlet implementation class ActivityServlet
 */
public class ActivityServlet extends HttpServletBase {
	private static final long serialVersionUID = 1L;

	@EJB
	private ActivityManagerRemote activityManager;

	@EJB
	private ProjectManagerRemote projectManager;

	/**
	 * @see HttpServletBase#HttpServletBase()
	 */
	public ActivityServlet() {
		super();
	}

	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		List<Activity> activityList = activityManager.getListByEmployeeId(
				currentEmployee.getId(), null);
		request.setAttribute("activityList", activityList);

		List<Project> projectList = projectManager
				.getListDashboardByEmployeeId(currentEmployee.getId());
		request.setAttribute("projectList", projectList);

		loadJSP(SiteParameters.getPagePath("activity"), request, response);
	}
}